<?php
session_start();
header("Content-type:text/html; charset=UTF-8");

include("../api/sms.php");
include("../api/random.php");

$mobile = $_POST['mobile'];
$send_code = $_POST['send_code'];
$smstype = $_POST['smstype'];

if(empty($mobile)){
	exit('手机号码不能为空');
}
if(empty($send_code)){
	exit('验证码不能为空');
}
if(empty($smstype)){
	exit('短信类型不能为空');
}
if(empty($_SESSION['session_verify']) or $send_code!=$_SESSION['session_verify']){
	//防用户恶意请求
	exit('验证码不正确，请重新输入或刷新页面后重试');
}
$content=random(6,1);
$sms = new Sms();
$result = $sms->Send($mobile,$content,$smstype);
if ($result->result->success){
	echo "短信发送成功";
	$_SESSION['session_smscode']=$content;
}else{
	echo "短信发送成功";
}
?>